#include <my_header.h>
/*Usage:./to_upper filename */
int main(int argc, char *argv[]) {
    ARGS_CHECK(argc, 2);

    int fd = open(argv[1], O_RDWR);
    ERROR_CHECK(fd, -1, "open");

    // ftruncate调整文件大小
    int ret = ftruncate(fd, 12);
    ERROR_CHECK(ret, -1, "ftruncate");

    char *p = (char*)mmap(NULL, 12, PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0 );
    ERROR_CHECK(p, MAP_FAILED, "mmap");

    for (size_t i = 0; i < 12; ++i) {
        p[i] = toupper(p[i]);
    }
    munmap(p, 12);
    close(fd);
    return 0;
}

